import { defineConfig } from 'vite'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import autoprefixer from 'autoprefixer'
import postcssPixelToRemPlugin from 'postcss-pxtorem'
import compression from 'vite-plugin-compression'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
export default defineConfig({
    resolve: {
        alias: {
            '@': path.resolve(__dirname, './src')
        }
    },
    plugins: [
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()]
        }),
        Components({
            resolvers: [ElementPlusResolver()]
        }),
        compression({
            algorithm: 'gzip', // 使用gzip压缩
            threshold: 10240, // 文件大小超过10KB时进行压缩
            deleteOriginFile: false // 是否删除原文件
        })
    ],
    css: {
        postcss: {
            plugins: [
                autoprefixer(),
                postcssPixelToRemPlugin({
                    rootValue: 16,
                    propList: ['*'],
                    selectorBlackList: ['ignore-'],
                    replace: true,
                    mediaQuery: false,
                    minPixelValue: 0
                })
            ]
        }
    }
})
